cmake_minimum_required(VERSION 3.0.0)
project(KcpStressTest)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "list of supported configurations." FORCE)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJECT_SOURCE_DIR}/../bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PROJECT_SOURCE_DIR}/../bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${PROJECT_SOURCE_DIR}/../lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${PROJECT_SOURCE_DIR}/../lib)

include_directories(${PROJECT_SOURCE_DIR}/kcp)

add_definitions(-D_WINSOCK_DEPRECATED_NO_WARNINGS)

message(STATUS ${CMAKE_CXX_PLATFORM_ID})
if(CMAKE_CXX_PLATFORM_ID STREQUAL "Windows")
elseif(CMAKE_CXX_PLATFORM_ID STREQUAL "Linux")
    add_compile_options(-std=c++11)
endif()

macro(group_src_by_dir SRC_LIST)
    foreach(SRC_PATH ${${SRC_LIST}})
        #message(STATUS ${SRC_PATH})
        string(REGEX REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/(.*)/.+$" \\1 GROUP_NAME ${SRC_PATH})
        #message(STATUS ${GROUP_NAME})
        if(NOT SRC_PATH STREQUAL GROUP_NAME)
            string(REPLACE "/" "\\" GROUP_NAME ${GROUP_NAME})
            source_group(${GROUP_NAME} FILES ${SRC_PATH})
        else()
            source_group("" FILES ${SRC_PATH})
        endif()
    endforeach(SRC_PATH)
endmacro(group_src_by_dir)

add_subdirectory(kcp)
add_subdirectory(kcp_server)
add_subdirectory(kcp_client)
